﻿#include "Holiday.h"
#include <sstream>

Holiday::Holiday(std::string day, std::string name, bool work, std::string target)
{
	if (day.find('-') == std::string::npos && day.length() >= 8) {
		Day = day.substr(0, 4) + "-" +
			day.substr(4, 2) + "-" +
			day.substr(6);
	}
	else {
		Day = day;
	}

	Name = name;
	Work = work;
	// 格式化 Target
	if (target.find('-') == std::string::npos && target.length() >= 8) {
		Target = target.substr(0, 4) + "-" +
			target.substr(4, 2) + "-" +
			target.substr(6);
	}
	else {
		Target = target;
	}
}


std::string Holiday::toString() const {
	std::ostringstream oss;
	oss << Day << " " << Name;
	if (Work) {
		oss << " 调休";
	}
	oss << " " << Target;
	return oss.str();
}

